/* 
 * File:   main.c
 * Author: privalov
 *
 * Created on 2 Апрель 2014 г., 2:14
 */

#include <stdio.h>
#include <stdlib.h>
#include "logger.h"
/*
 * 
 */
pthread_mutex_t mutex;
pthread_mutex_t mutex2;
void* sendFunc1(void* atr){
    pthread_mutex_lock(&mutex2);
    char* msg=(char*)malloc(25);
    sprintf(msg,"ZERO msg TEST THREAD #%i\n",*((int*)atr));
    sendMsg(DEBUG,msg);
    free(msg);
    pthread_mutex_unlock(&mutex2);
    pthread_exit(NULL);
}
void* sendFunc(void* atr){
    char* msg=(char*)malloc(25);
    sprintf(msg,"ZERO msg TEST THREAD #%i\n",*((int*)atr));
    sendMsg(DEBUG,msg);
    free(msg);
    
    pthread_exit(NULL);
}


int main(int argc, char** argv)
{
    SEND_DEBUG("I<3u\n");
    log_init(DEBUG|ERROR,"./log.log",0x10000);
    pthread_t nthng;
    pthread_mutex_init(&mutex,NULL);
    int i;
    char* msg=(char*)malloc(25);
    for(i=0;i<0x9;i++){
        pthread_create(&nthng, NULL, sendFunc, &i);
        msg=(char*)malloc(25);
        sprintf(msg,"%2i\n",i);
        sendMsg(DEBUG,msg);
        free(msg);
    }
    SEND_INFO("some info\n");
    log_deinit();
    SEND_DEBUG("I<3u\n");
    return (EXIT_SUCCESS);
}

